home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / enscript.4 / enscript / enscript-1.4.0 / afmlib / strhash.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-27  |  2.7 KB  |  89 lines

  1. /* 
  2.  * String hash table.
  3.  * Copyright (c) 1995 Markku Rossi.
  4.  *
  5.  * Author: Markku Rossi <mtr@iki.fi>
  6.  */
  7.  
  8. /*
  9.  * This file is part of the AFM library.
  10.  * 
  11.  * This library is free software; you can redistribute it and/or
  12.  * modify it under the terms of the GNU Library General Public
  13.  * License as published by the Free Software Foundation; either
  14.  * version 2 of the License, or (at your option) any later version.
  15.  *
  16.  * This library is distributed in the hope that it will be useful,
  17.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  19.  * Library General Public License for more details.
  20.  *
  21.  * You should have received a copy of the GNU Library General Public
  22.  * License along with this library; if not, write to the Free
  23.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  */
  25.  
  26. #ifndef STRHASH_H
  27. #define STRHASH_H
  28.  
  29. #ifndef __P
  30. #if PROTOTYPES
  31. #define __P(protos) protos
  32. #else /* no PROTOTYPES */
  33. #define __P(protos) ()
  34. #endif /* no PROTOTYPES */
  35. #endif
  36.  
  37. typedef struct stringhash_st *StringHashPtr;
  38.  
  39. /*
  40.  * Init a hash and return a hash handle or NULL if there were errors.
  41.  */ 
  42. StringHashPtr strhash_init __P ((void));
  43.  
  44. /*
  45.  * Free hash <hash>. Frees all resources that hash has allocated. <hash> 
  46.  * shouldn't be used after this function is called.
  47.  */
  48. void strhash_free __P ((StringHashPtr hash));
  49.  
  50. /*
  51.  * Put key <key> to hash <hash>. <data> will be bind to <key>. Returns
  52.  * true (1) if operation was successful or false (0) otherwise. If <key>
  53.  * is already bind to another data, then <old_data> will be set to old
  54.  * data. Otherwise it will be set to NULL.
  55.  */
  56. int strhash_put __P ((StringHashPtr hash, char *key, int keylen, void *data,
  57.               void **old_data_return));
  58.  
  59. /*
  60.  * Get data associated to key <key>. Data is returned in <*data>. 
  61.  * Returns true (1) is key was found or false (0) otherwise.
  62.  */
  63. int strhash_get __P ((StringHashPtr hash, const char *key, int keylen,
  64.               void **data_return));
  65.  
  66. /*
  67.  * Deletes key <key> form <hash>. Data is returned in <*data>. Returns
  68.  * true (1) if <key> was found or false (0) if <key> was not found or
  69.  * errors were encountered.
  70.  */
  71. int strhash_delete __P ((StringHashPtr hash, const char *key, int keylen,
  72.              void **data_return));
  73.  
  74. /*
  75.  * Get first item from hash <hash>.  Returns 1 if there were items
  76.  * or 0 otherwise.
  77.  */
  78. int strhash_get_first __P ((StringHashPtr hash, char **key_return,
  79.                 int *keylen_return, void **data_return));
  80.  
  81. /*
  82.  * Get next item from hash <hash>.  Returns 1 if there were items
  83.  * or 0 otherwise.
  84.  */
  85. int strhash_get_next __P ((StringHashPtr hash, char **key_return,
  86.                int *keylen_return, void **data_return));
  87.  
  88. #endif /* not STRHASH_H */
  89.